//
//  ZDQWarningTableViewCell.m
//  Alltelevisionnews
//
//  Created by dllo on 15/12/2.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ZDQWarningTableViewCell.h"

@implementation ZDQWarningTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self create];
        
    }
    
    return self;
    
}



- (void)create {
    
    self.photoImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.photoImageView];
    self.photoImageView.image = [UIImage imageNamed:@"warning.png"];
    
    self.titleLabel = [[UILabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.text = @"每日提醒";
    
    self.switchView = [[UISwitch alloc] init];
    [self.contentView addSubview:self.switchView];
    [self.switchView addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
//    self.switchView.layer.borderWidth = 1;
    
}



- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    [self.photoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(10);
        make.left.equalTo(self.contentView).with.offset(10);
        make.width.equalTo(self.contentView.mas_width).with.offset(-self.contentView.frame.size.width / 8 * 7 - 20 * self.contentView.frame.size.width / 375);
        make.bottom.equalTo(self.contentView).with.offset(-10);
        
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).with.offset(5);
        make.left.equalTo(self.photoImageView.mas_right).with.offset(10);
        make.width.equalTo(self.contentView.mas_width).with.offset(-self.contentView.frame.size.width / 4 * 3);
        make.bottom.equalTo(self.contentView).with.offset(-5);
        
    }];

    [self.switchView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).with.offset(5);
        make.right.equalTo(self.contentView).with.offset(-10);
        make.bottom.equalTo(self.contentView).with.offset(0);
        make.width.equalTo(self.contentView.mas_width).with.offset(-self.contentView.frame.size.width / 6 * 5);
        
    }];

    
}





- (void)buttonAction:(UISwitch *)button {
    
    [self.delegate clickbutton:self.switchView.on];
    
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
